package com.ruoyi.common.utils;


import com.ruoyi.common.core.domain.zzw.InvateInfo;
import com.ruoyi.common.core.domain.zzw.VedioQuery;
import com.ruoyi.common.core.domain.zzw.Vedios;
import com.xylink.sdk.SdkMethodV2;
import com.xylink.util.Result;
import com.xylink.util.SignatureSample;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class RecordControllApi {
    private static SignatureSample signatureSample = new SignatureSample();
    private static final String prefixUrl = "/api/rest/external/v1/meeting/recording/";

    public RecordControllApi() {
    }

    private String getPrefixUrl() {
        return "/api/rest/external/v1/meeting/recording/";
    }

    public Result pauseRecording(String enterpriseId, String meetingRoomNumber) throws IOException {
        String surl = this.getPrefixUrl() + meetingRoomNumber + "/pause?enterpriseId=" + enterpriseId;
        return SdkMethodV2.sdkGet(surl,null);
    }

    public Result invate(String enterpriseId, InvateInfo vedioQuery) throws IOException {
        String surl = "/api/rest/external/v1/conferenceControl/invitation?enterpriseId=ac0363b754a0afe5bd7378d81cff5e23a41ea293";
        return SdkMethodV2.sdkPut(surl,vedioQuery,InvateInfo.class);
    }

    public Result resumeRecording(String enterpriseId, String meetingRoomNumber) throws IOException {
        String surl = this.getPrefixUrl() + meetingRoomNumber + "/resume?enterpriseId=" + enterpriseId;
        return SdkMethodV2.sdkGet(surl,null);
    }


    public Result downloadBysession(String enterpriseId, String sessionId) throws IOException {
        String surl = "/api/rest/external/v1/vods/session/"+sessionId+"/downloadurl?enterpriseId=" + enterpriseId;
        return SdkMethodV2.sdkGet(surl,null);
    }

    public Result queryVedio(String enterpriseId, VedioQuery vedioQuery) throws IOException {
        String surl = "/api/rest/external/v1/meetingroom/vods/page?enterpriseId=" + enterpriseId;
        return SdkMethodV2.sdkPut(surl,vedioQuery, Vedios.class);
    }

    public Result deleteVedio(String enterpriseId, String callNumber) throws IOException {
        String surl = "/api/rest/external/v1/vods/recycle/meetingRoomNumber/delete?enterpriseId=" + enterpriseId + "&meetingRoomNumber=" + callNumber;
        return SdkMethodV2.sdkDelete(surl,null);
    }

    public Result delete(String enterpriseId, String vodId) throws IOException {
        String surl = "/api/rest/external/v1/vods/"+ vodId +"?enterpriseId=" + enterpriseId;
        return SdkMethodV2.sdkDelete(surl,null);
    }

    public Result startRecording(String enterpriseId, String callNumber) throws IOException {
        String surl = this.getPrefixUrl() + callNumber + "/start?enterpriseId=" + enterpriseId;
        return SdkMethodV2.sdkGet(surl,null);
    }

    public Result stopRecording(String enterpriseId, String callNumber) throws IOException {
        String surl = this.getPrefixUrl() + callNumber + "/stop?enterpriseId=" + enterpriseId;
        return SdkMethodV2.sdkGet(surl,null);
    }

    public Result deleteMeetingRecord(String enterpriseId, String callNumber) throws IOException {
        String surl = "/api/rest/external/v1/meetingroom/"+ callNumber +"/vods?enterpriseId=" + enterpriseId;
        return SdkMethodV2.sdkDelete(surl,null);
    }
}
